#ifndef AFX_DYSvrNetMan_H__INCLUDED_
#define AFX_DYSvrNetMan_H__INCLUDED_

#include "DYListenThread.h"
#include "SvrNetSessionMan.h"



class DYSvrNetMan 
{
public:
	DYSvrNetMan(void);
	~DYSvrNetMan(void);

public:
	int SetConnectTime(UINT32 nWaitTime, UINT32 nTryTimes);
	int SetListen(UINT16 nPort1 = 9000, UINT16 nPort2 = 9001, UINT16 nPort3 = 9002);



public:
	int SvrStart();
	int SvrStop();

public:
	int TcpDispatch(UINT16 nType,SOCKET hClientSocket,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpDispatch(UINT16 nType,SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);


//Anchor
private:
	int TcpAnchorDispatch(SOCKET hClientSocket,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpAnchorDispatch(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpAnchorCommand(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);

//Session
private:
	int TcpViewerDispatch(SOCKET hClientSocket,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpViewerDispatch(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpViewerCommand(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);

//Audience
private:
	int TcpAudienceDispatch(SOCKET hClientSocket,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpAudienceDispatch(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpAudienceCommand(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	void	SendAllAnchorToUser(SOCKET sock);

public:
	enum _eListenType
	{
		eAnchorListen,
		eViewerListen,
		eAudienceListen,
	};
	DYListenThread m_xAnchorListen;
	DYListenThread m_xViewerListen;
	DYListenThread m_xAudienceListen;


public:
	SvrNetSessionMan m_xSessionMan;


public:

	
};

#endif